import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/layout'
Vue.use(VueRouter)

export const constantRoutes = [
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  {
    path: '/login',
    name: 'Login',
    hidden: true,
    component: () => import("../views/login"),
    meta: { title: '登录', icon: 'xianxingnanzilan' ,affix: false , white:true }
  },
]
// 本地所有的页面 需要配合后台返回的数据生成页面
export const asyncRoutes = [
  {
    path: '/',
    name: 'Indexbox',
    component: Layout,
    redirect: '/index',
    meta: { title: '首页', Level:true, icon: 'el-icon-platform-eleme' ,affix: true ,roles: ['admin', 'editor'] },
    children: [
      {
        path: '/index',
        name: 'Index',
        component: () => import("../views/index"),
        meta: { title: '首页',id: '1', icon: 'el-icon-platform-eleme' ,affix: true ,roles: ['admin', 'editor'] }
      }
    ]
  },
  {
    path: "/putIn",
    component:  Layout,
    redirect: "/putIn/ad_putin",
    meta: { title: "投放管理", Level:true, icon: "el-icon-s-marketing",affix: false , roles: ['admin', 'editor']   },
    children: [
        {
            path: "ad_putin",
            name: "ADputin",
            component: () => import("../views/putIn/ad_putin.vue" ),
            meta: { title: "广告投放管理",id: '2',  affix: false , roles: ['admin', 'editor']  },
        },
        {
            path: "material",
            name: "Material",
            component: () => import("@/views/putIn/material.vue"),
            meta: { title: "物料管理", id: '3', affix: false , roles: ['admin', 'editor']    },
        },
    ],
  },
  {
      path: "/resources",
      component:  Layout,
      redirect: "/resources/code",
      name: "resources",
      meta: { title: "代码位管理", Level:true, icon: "el-icon-s-order" ,affix: false , roles: ['admin', 'editor'] },
      children: [
          {
              path: "code",
              name: "Code",
              component: () => import("@/views/resources/code.vue"),
              meta: { title: "代码位", id: '4', affix: false , roles: ['admin', 'editor']  },
          },
          {
              path: "codegroup",
              name: "codegroup",
              component: () => import("@/views/resources/codegroup.vue"),
              meta: { title: "代码位组",id: '5', affix: false , roles: ['admin', 'editor']  },
          },
          {
            path: "codetemplate",
            name: "codetemplate",
            component: () => import("@/views/resources/codetemplate.vue"),
            meta: { title: "自定义模板",id: '6',affix: false , roles: ['admin', 'editor']  },
          },
          // {
          //     path: "Media",
          //     name: "Media",
          //     component: () => import("@/views/resources/Media.vue"),
          //     meta: { title: "媒体管理" ,affix: true , roles: ['admin', 'editor']  },
          // },
      ],
  },
  {
      path: "/report",
      component:  Layout,
      redirect: "/report/report-zy",
      name: "report",
      meta: { title: "报告", Level:true, icon: "el-icon-s-data",affix: false , roles: ['admin', 'editor']  },
      children: [
          // {
          //     path: "report-zy",
          //     name: "ReportZy",
          //     component: () => import("@/views/report/report-zy.vue"),
          //     meta: { title: "资源报告",  icon: "el-icon-s-data" ,affix: false , roles: ['admin', 'editor']  },
          // },
          {
              path: "report-code",
              name: "ReportCode",
              component: () => import("@/views/report/report-code.vue"),
              meta: { title: "代码位报告",id: '7', affix: false , roles: ['admin', 'editor']  },
          },
          {
              path: "report-Advertising",
              name: "ReportAdvertising",
              component: () => import("@/views/report/report-Advertising.vue"),
              meta: { title: "投放报告", id: '8', affix: false , roles: ['admin', 'editor']  },
          },
          {
              path: "report-material",
              name: "ReportMaterial",
              component: () => import("@/views/report/report-material.vue"),
              meta: { title: "物料报告", id: '9',  affix: false , roles: ['admin', 'editor']  },
          },
          {
              path: "report-details",
              name: "ReportDetails",
              component: () => import("@/views/report/report-details.vue"),
              meta: { title: "点击详情", id: '10',  affix: false , roles: ['admin', 'editor']  },
          },
      ],
  },
  {
      path: "/permission",
      component:  Layout,
      redirect: "/permission/admin",
      // name: "admin",
      meta: { title: "账户与设置", Level:true, icon: "el-icon-s-custom" ,affix: false , roles: ['admin', 'editor'] },
      children: [
          {
              path: "admin",
              name: "Admin",
              component: () => import("@/views/permission/admin.vue"),
              meta: { title: "管理员" , icon: "el-icon-s-custom" , id: '11', affix: false , roles: ['admin', 'editor'] },
          },
          // {
          //     path: "operateLog",
          //     name: "OperateLog",
          //     component: () => import("@/views/permission/operateLog.vue"),
          //     meta: { title: "操作日志",affix: false , roles: ['admin', 'editor']  },
          // },
      ],
  },
  {
    path: '/:catchAll(.*)',
    name: 'NotFound',
    hidden: true,
    component: () => import("../views/404"),
    meta: { title: '404',Level:true, icon: 'xianxingnanzilan' ,affix: true , white:true }
  },
]
  // Product:{
  //   component: () => import('@/views/product/index'),   //商品列表
  // },
  // Productadd:{
  //   component: () => import('@/views/product/add.vue'),   //新增商品列表
  // },
  // Role:{
  //   component: () => import('@/views/permission/role.vue'),   //角色列表
  // },
  // Aminlist:{
  //   component: () => import('@/views/permission/adminlist.vue'),   //管理员列表
  // },
  // Menu:{
  //   component: () => import('@/views/permission/menu.vue'),   //菜单列表
  // },
  // // addd
  // ADputin:{
  //   component: () => import('@/views/putIn/ad_putin.vue'),   //广澳投放管理
  // },
  // Material:{
  //   component: () => import('@/views/putIn/material.vue'),   //物料管理
  // },
  // Code:{
  //   component: () => import('@/views/resources/code.vue'),   //资源管理-代码位管理
  // },
  // Media:{
  //   component: () => import('@/views/resources/Media.vue'),   //资源管理-媒体管理
  // },
  // ReportZy:{
  //   component: () => import('@/views/report/report-zy.vue'),   //资源报告
  // },
  // Accvip:{
  //   component: () => import('@/views/permission/accvip.vue'),   //账户与会员管理
  // },
  // OperateLog:{
  //   component: () => import('@/views/permission/operateLog.vue'),   //操作日志
  // },
const createRouter = () => new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}
export default router
